package com.sgb.kjwl.view.ui.adapter.home;

import android.content.Context;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.DeviceEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.MDateUtil;

import java.util.List;

public class RecommandAdapter extends BaseRecycleAdapter<DeviceEntity> {

    private TextView contentView;
    private TextView priceView;

    public RecommandAdapter(Context context, List<DeviceEntity> datas) {
        super(context, R.layout.item_recommand, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final DeviceEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        contentView = holder.getItem().findViewById(R.id.content_view);
        TextView time = holder.getItem().findViewById(R.id.time);
        priceView = holder.getItem().findViewById(R.id.price_view);
        contentView.setText(entity.getProvinceName() + entity.getCityName() + entity.getDistrictName());
        if (entity.getNegotiable().equals("1")) {
            priceView.setText("面议");
        } else {
            priceView.setText(entity.getPrice() + entity.getUnitName());
        }

        time.setText(MDateUtil.getDate(entity.getCreateTime()));
    }

}
